/*
 * TabbarNav 顶部导航条
*/
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15

Item {
    id: root
    /* property 定义开始 */
    property string title: "--TabbarNav Default--"
    property bool isEnable: true

    // 信号
    signal returnSig()
    signal openDoor()
    /* property 定义结束 */

    implicitHeight: tabbarNav.height

    Rectangle {
        id: tabbarNav
        width: parent.width
        height: 56
        color: "#4D000000"

        // 标题
        Label {
            id: titleContents
            anchors.fill: parent
            font.family: "Alibaba PuHuiTi"
            font.bold: true
            font.pixelSize: 22
            color: "#FFF"
            verticalAlignment: Text.AlignVCenter
            horizontalAlignment: Text.AlignHCenter
            text: qsTr(title)
        }

        // 返回按钮
        Rectangle {
            id: rtnbtn
            width: 84
            height: parent.height
            anchors.left: parent.left
            color: "transparent"
            z: 99

            // 图标和文字
            // 返回图标
            Image {
                anchors.fill: parent
                fillMode: Image.Stretch
                source: "qrc:/icons/back.png"
                smooth: true
            }

            // 返回文字
            Label {
                text: qsTr("返回")
                font.family: "Alibaba PuHuiTi"
                font.pixelSize: 14
                font.bold: true
                color: "#FFF"
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 18
            }

            MouseArea {
                enabled: isEnable
                anchors.fill: parent
                cursorShape: isEnable ? Qt.PointingHandCursor : Qt.ArrowCursor
                onClicked: root.returnSig()
            }
        }

        // 打开仓门
        Rectangle {
            id: openDoorBtn
            width: 110
            height: parent.height
            anchors.right: parent.right
            color: "transparent"
            z: 99

            // 图标和文字
            // 打开仓门图标
            Image {
                anchors.fill: parent
                fillMode: Image.Stretch
                source: "qrc:/icons/open_door.png"
                smooth: true
            }

            // 打开仓门文字
            Label {
                text: qsTr("打开仓门")
                font.family: "Alibaba PuHuiTi"
                font.pixelSize: 14
                font.bold: true
                color: "#FFF"
                anchors.verticalCenter: parent.verticalCenter
                anchors.right: parent.right
                anchors.rightMargin: 13
            }

            MouseArea {
                enabled: isEnable
                anchors.fill: parent
                cursorShape: isEnable ? Qt.PointingHandCursor : Qt.ArrowCursor
                onClicked: root.openDoor()
            }
        }

    }
}
